package
{
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.geom.Point;

	public class Player extends Objekt
	{
		var target:Point;
		var relPos:Point;
		var moveContainer:MovieClip;
				
		public function Player(parent:DisplayObjectContainer, iMoveContainer:MovieClip, xBounds:Array, yBounds:Array)
		{
			super(parent,xBounds,yBounds);
			relPos = new Point(this.x, this.y);
			target = new Point(200, 200);
			moveContainer = iMoveContainer;
		}
		
		override public function moveObject():void
		{	
			var dl:Number = Math.sqrt(direction.x*direction.x + direction.y*direction.y);
			var targetVector:Point = new Point(target.x-this.x,target.y-this.y);
			var tl:Number = Math.sqrt(targetVector.x*targetVector.x + targetVector.y*targetVector.y);
						
			// TODO: bewegt sich merkwürdig... wtf?
			
			direction.x = targetVector.x*0.1;
			direction.y = targetVector.y*0.1;
			//if ( relPos.y >= yBounds[1] || relPos.y <= yBounds[0] ) direction.x *= -1;
			//if ( relPos.x >= xBounds[1] || relPos.x <= xBounds[0] ) direction.y *= -1;
			
			relPos.x += direction.x * speed;
			relPos.y += direction.y * speed;
			target.x -= direction.x * speed;
			target.y -= direction.y * speed;
			moveContainer.x -= direction.x * speed;
			moveContainer.y -= direction.y * speed;
		}
	}
}